package com.inspur.iaic.controller;

import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.inspur.iaic.data.NginxLog;
import com.inspur.iaic.service.RealTimeAccessLogProcessor;
import com.inspur.iaic.service.WarnAccessLogProcessor;

@Controller
@RequestMapping(value = "/access/log")
public class AccessLogController {
	@Autowired
	private WarnAccessLogProcessor warnAccessLogProcessor;
	@Autowired
	private RealTimeAccessLogProcessor realTimeAccessLogProcessor;

	@GetMapping("/realtime")
	@ResponseBody
	public List<NginxLog> realtime() {
		NginxLog[] allLog = realTimeAccessLogProcessor.getAll();
		return Arrays.asList(allLog);
	}

	@GetMapping("/warn")
	@ResponseBody
	public List<NginxLog> warn() {
		NginxLog[] allLog = warnAccessLogProcessor.getAll();
		return Arrays.asList(allLog);
	}
}
